package util;

import java.util.Random;
import java.util.TreeSet;

public class RandomUtils {

    public static TreeSet<Integer> randomNPoints(int n, int length, Random random) {
        //  随机选择n个不同的节点
        TreeSet<Integer> randList = new TreeSet<>();
        while (randList.size() <= n) {
            int rand = random.nextInt(length - 1) + 1; // [1,n)
            randList.add(rand);
        }
        return randList;
    }
}
